PackageStore.AddPackageReference Method

Creates and executes a LearningStoreJob to add a package reference to the PackageStore.

Parent Type: PackageStore

Namespace: Microsoft.LearningComponents.Storage

Assembly: Microsoft.LearningComponents.Storage.dll

Syntax
C#

protected AddPackageReferenceResult AddPackageReference (
PackageReader packageReader,
string location,
PackageEnforcement packageEnforcement

)

Parameters

packageReader

The package to be added to PackageStore. This is required.

location

The value of the Location field of the package. This should uniquely identify the location of the package so that it can be used to retrieve files from the package at a later time. The value of the location may be updated later using UpdatePackageLocation. The location value may not be a null or empty string.

packageEnforcement

The settings to determine whether data should be modified in order to enable the package reference to be added. Requesting the data to be modified will increase the likelihood the package reference will be added successfully, however it may cause unexpected problems later when the package is executed.

Return Value

The results of the addition of the reference, including a log containing any warnings encountered during the process.

Exceptions
Exception type Condition
PackageImportException

Thrown if the package reference could not be added.

ArgumentNullException

Thrown if packageReader or location or packageEnforcement is null.

ArgumentException

Thrown if location is not provided.

Remarks

This method validates the package according the to requested manifestSettings. If the validation results in any errors, the package reference will not be added. The reason for the error will be available in the log which is included in the exception. The validation process will stop at the first error, so if the process is stopped, the log may not contain a complete listing of all problems in the package.